#include <Mitrix_Path.h>
#include <Map.h>
#include <cstdlib>
#include <time.h>
using namespace M_M_Map;
class PRM
{
private:
    /* data */
    Mitrix_M_Map* M_Map;
    
    bool point_exists(m_position p){
        for(int i=0;i<random_points.size();i++){
            if(position_equals(random_points.at(i),p))
                return true;
        }
        return false;
    }
public:
    vector<m_position> random_points;
    PRM(/* args */Mitrix_M_Map* m);
    ~PRM();
    void SamplePoints(int k);
    
};

PRM::PRM(/* args */Mitrix_M_Map* m)
{
    this->M_Map=m;
}

PRM::~PRM()
{
}
// k means count of the random points
void PRM::SamplePoints(int k){
    unsigned seed=time(0);
    srand(seed);
    for(int i=0;i<k;i++){
        int row=rand()%this->M_Map->getHeight();
        int col=rand()%this->M_Map->getLength();
        while(!this->M_Map->isValid({row,col})){
            row=rand()%this->M_Map->getHeight();
            col=rand()%this->M_Map->getLength();
        }
        if(point_exists({row,col})){
            continue;
        }
        random_points.insert(random_points.end(),{row,col});
    }
}